﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Trains.Common.FileHelper
{
    public class FileHelper
    {
        private static string FILE_NAME = "routes.txt";

        public static string LoadFile()
        {
            var fullRoutes = new List<string>();
            var environment = Environment.CurrentDirectory.IndexOf("Trains.Tests") > -1 ? Environment.CurrentDirectory.Split("Trains.Tests")[0] + "\\" + "Trains" : Environment.CurrentDirectory;
            StreamReader sr = File.OpenText(environment  + "\\" + FILE_NAME);

            string lineRoute;

            while ((lineRoute = sr.ReadLine()) != null)
            {
                fullRoutes.Add(lineRoute);
            }

            sr.Close();

            return string.Join(",", fullRoutes);
        }
    }
}
